<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/6/7
 * Time: 10:29
 */

namespace common\Controller;

use common\service\admin\LoginService;
use yii;
use yii\web\Controller;

class AdminController extends Controller
{
    public $service;

    /**
     * Des:校验是否登录
     * Name: beforeAction
     * @param yii\base\Action $action
     * @return bool
     * @author 倪宗锋
     */
    public function beforeAction($action)
    {
        $checkLogin = LoginService::checkLogin();
        if ($checkLogin['flag'] == false) {
            Yii::$app->response->format = 'json';
            Yii::$app->response->data = $checkLogin;
            return false;
        }
        $_COOKIE['admin_uid'] = LoginService::$uid;
        return true;
    }
}